/* * When the it recive 1 from the master it will turn OFF the LED if it recive 0 it will turn ON. * Originaly Made by Eidha alrashdi and edited * fabacadmy2018 *20/6/2018 * Edited by Danny Vallejo fab academy 27/04/2019 * This program causes when read the message "d" blink the led 3 times. There is a issue I had to connect tx with tx and rx with rx and work well. */ #include// add serial library int rxPin = 1;// the receiver will be in pin 1 int txPin = 0;// the sender will be in pin 0 char val = 'd';// defining that val is equal to 1 int Loops = 0; SoftwareSerial myserial(rxPin, txPin);// defin the serial and indecate the ports. void setup() { myserial.begin(9600); pinMode(8, OUTPUT);// pin 8 is the LED } void loop() { char chr = myserial.read();// chr equal whatever the serial read from the master if (chr == val) {// here I'm saying if the serial read a valuy equal to what val is, turn LED ON and send that it receive for (int x = 0; x < 3; x++) { digitalWrite(8, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(8, LOW); // set the LED off delay(500); // wa } } }